package config

import (
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	Mysql struct {
		Host     string
		Port     string
		Username string
		Password string
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		Database int
	}
	QiNiuYun struct {
		AccessKey string
		SecretKey string
		Url       string
		Bucket    string
	}
	BaiDuYun struct {
		AppId     string
		ApiKey    string
		SecretKey string
	}
	Jwt struct {
		AppKey string
	}
}

var DataConfig AppConfig

func Init() {
	viper.SetConfigFile("../../config/config.yaml")
	if err := viper.ReadInConfig(); err != nil {
		panic(err)
	}
	err := viper.Unmarshal(&DataConfig)
	if err != nil {
		panic(err)
	}
	log.Println("Config File Read Success!", DataConfig)
}
